package com.it.system.gatewayservice.config;

import jakarta.annotation.Resource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.Set;

@Configuration
@ConfigurationProperties(prefix = "user-login-gateway")
public class WhiteListConfig {

    public static final String KEY="white-list";

    @Resource
    private RedisTemplate<String,String> redisTemplate;

    /**
     * 读取白名单
     */
    public Set<String> getWhiteList(){
        //从redis读取白名单
        return redisTemplate.opsForSet().members(KEY);
    }

    /**
     * 添加白名单
     * @param whiteList
     */
    public void setWhiteList(String...urls) {
        redisTemplate.opsForSet().add(KEY, urls);
    }

}
